<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>页面相关</title>
</head>
<body>
    <input type="text">
    <input type="button" value="添加文本" onclick="f1()">
    <input type="button" value="添加图片" onclick="f2()">
    <script>
        let i = document.querySelector("input")
        function f1(){
            // 添加h1标签
            let h = document.createElement("h1")
            // 把文本框的内容传给h1
            h.innerText = i.value;
            // 把h1添加到页面中
            document.body.append(h)
        }
        function f2(){
            // 添加图片标签
            let ig = document.createElement("img")
            // 将文件路径传给img
            ig.src = "../notos/img/image-20230818203113547.png"
            
            // 将图片传给页面
            document.body.append(ig)
        }
    </script>
</body>
</html>